# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dtc
pkgver=1.6.1
pkgrel=1
pkgdesc="Device Tree Compiler"
url="https://git.kernel.org/pub/scm/utils/dtc/dtc.git/"
arch="all"
license="GPL-2.0-or-later"
makedepends="bison flex python3-dev swig"
checkdepends="coreutils"
subpackages="$pkgname-dev libfdt py3-libfdt:py3_libfdt"
source="https://kernel.org/pub/software/utils/dtc/dtc-$pkgver.tar.xz
	install-pylibfdt-to-destdir.patch
	pylibfdt-fix-with-Python-3.10.patch
	"

prepare() {
	default_prepare
	sed -i s:-Werror::g "$builddir"/Makefile
}

build() {
	make
}

check() {
	make check
}

package() {
	make -j1 DESTDIR="$pkgdir" PREFIX=/usr install
	rm -f "$pkgdir"/usr/lib/*.a
}

libfdt() {
	pkgdesc="Device tree library"
	amove usr/lib/libfdt*
}

py3_libfdt() {
	pkgdesc="Device tree library for Python 3"
	depends="python3"
	amove usr/lib/python3*
}

sha512sums="
26cd351ddca411ab96b93ac3e763f817f9f8a80ca66a8707e1077f771ed8e7e04c01f321ab8ab27b2f9826d9d438483fe3156401493bfd29cef3cc71a1414568  dtc-1.6.1.tar.xz
1c43dfae8d15861c4f0170f0df9ba63d197ab3be50e39fe5748e547074c52dc7b042ca5e9c64d3d4bb0a8e8cde8df7e71660cde93e9512923405c38debcaa01c  install-pylibfdt-to-destdir.patch
1c7d2b5f7dcb8aed38a1b685e3be30497988933c2149a169b20fb2df53c44b8584cfdb9bad695a5d357598e33bf85cddb38397477862d46e2de69e46fc53556a  pylibfdt-fix-with-Python-3.10.patch
"
